/**********************************************************************
* File: location.cpp
* ID  : 
* Purpose: Implementation of class Location.
* Date   : 2004/04/23
* Author : T.S.Yo
* Description:
*    Methods include: constructor, destrctor, setDataMember, and
*        getDataMember
**********************************************************************/

#ifndef LOCATION_CPP
#define LOCATION_CPP

#include <string>
#include <iostream>
#include "location.h"

using namespace std;

// Constructor
Location::Location(){};

// Destructor
Location::~Location(){}; 
        
// Get Data Member
int Location::getKey() const
{return ID;}

int Location::getID()
{return ID;}

int Location::getExit(const char &direction)
{
    int locID;
    switch(direction)
    {
        case 'n':
            locID = exit[0];
            break;
        case 's':
            locID = exit[1];
            break;
        case 'e':
            locID = exit[2];
            break;
        case 'w':
            locID = exit[3];
            break;
        case 'u':
            locID = exit[4];
            break;
        case 'd':
            locID = exit[5];
            break;
        default:
            locID = -2;
            break;
    }
    return locID;
}

int Location::getPoint()
{return point;}

bool Location::getAccessed()
{return accessed;}

string Location::getName()
{return name;}

string Location::getSDescr()
{return sDescr;}

string Location::getLDescr()
{return lDescr;}

void Location::showItemList()
{itemList.showStructure();}

// Set Data Member
void Location::setID(const int &newID)
{ID = newID;}

void Location::setExit(const int &newExit, const char &direction)
{
    switch(direction)
    {
        case 'n':
            exit[0] = newExit;
            break;
        case 's':
            exit[1] = newExit;
            break;
        case 'e':
            exit[2] = newExit;
            break;
        case 'w':
            exit[3] = newExit;
            break;
        case 'u':
            exit[4] = newExit;
            break;
        case 'd':
            exit[5] = newExit;
            break;
        default:
            break;
    }
}

void Location::setName(const string &newName)
{name = newName;}

void Location::setAccessed(const bool &newAccessed)
{accessed = newAccessed;}

void Location::setPoint(const int &newPoint)
{point = newPoint;}

void Location::setSDescr(const string &newSDescr)
{sDescr = newSDescr;}

void Location::setLDescr(const string &newLDescr)
{lDescr = newLDescr;}

void Location::addItem(const Item &newItem)
{itemList.insert(newItem);}

void Location::dropItem(const string &itemName)
{
    Item searchItem;
    itemList.search(itemName, searchItem);
    itemList.remove();
}

// Access itemList
bool Location::searchItem(const string &itemName, Item &searchItem)
{
    bool result;
    result = itemList.search(itemName, searchItem);
    return result;
}

        
#endif    //#ifndef LOCATION_CPP

